﻿(function ($) {
    $('#nineseas-reader-content').on("heightChanged", function () {
        var panelHeight = $('#nineseas-reader-content').height() - 15;
        if (panelHeight < 400) panelHeight = 400;
        $("#authoring-tabs .ui-tabs-panel").css("height", panelHeight + "px");
    });

    $(document).ready(function () {
        var hasProfile = $("#authoring-tabs").attr("hasProfile");
        if (!hasProfile) hasProfile = "0";
        var selected = hasProfile == "1" ? 0 : 2;
        $("#authoring-tabs").tabs({
            active: selected,
            disabled: hasProfile == "1" ? null : [0, 1, 3],
            beforeLoad: function (event, ui) {
                $.commandBar('#nineseas-reader-footer');

                ui.jqXHR.error(function () {
                    ui.panel.html($(".authoring-tab-load-failed").html());
                });
            }
        }).addClass("ui-tabs-vertical ui-helper-clearfix").removeClass("ui-corner-all").removeClass("ui-widget-content");
        $("#authoring-tabs ul").removeClass("ui-widget-header");
        $("#authoring-tabs li").removeClass("ui-corner-top");
    });
})(jQuery);